<?php
defined('IN_YuLin') || exit('NO PERMIT!');

if(IS_POST){
	if($a == 'delete'){
		$ids = $_POST['ids'];
		foreach ($ids as $k => $v) {
			$ids[$k] = trim(NoBadStr($v));
		}
		$sql = "select id from ".Table('weblist')." where tid = 2 and id in (".implode(',', $ids).")";
		$rows = $db->affected_rows($sql);
		($rows != count($ids)) && AjaxReturn(['error'=>'0','msg'=>'操作失败'.$rows.'-'.count($ids).'-'.implode(',', $ids)]);
		$db->exec("delete from ".Table('weblist')." where id in (".implode(',', $ids).")");
		AjaxReturn(['error'=>'0','msg'=>'操作成功']);
	}
}

$sql = "select id,url,remark,inputtime from ".Table("weblist")." where tid = 2 ";
switch ($a) {
	case 'search':
		$w = $_POST['upuid'] == '0' ? '' : 'and wid = '.$_POST['upuid'];
		$w .= empty(trim($_POST['searchUrl'])) ? '' : " and url = '".trim($_POST['searchUrl'])."'";
		$sql .= $w;
		break;
	
	default:		
		
		break;
}
$data = $db->getall($sql);
$tpl->display($m.'/'.$c);
?>